<template>
  <div class="list">
    <el-tabs v-model="system">
      <el-tab-pane label="关于我们" name="first">
        <div style="">
          <tinymce v-model="formData.us_me" :height="300" />
        </div>

        <div class="container">
          <el-button type="primary" class="btn-sub" @click="toSub()">提交</el-button>
        </div>

      </el-tab-pane>
      <el-tab-pane label="隐私政策" name="second">
        <div style="">
          <tinymce v-model="formData.privacy_agreement" :height="300" />
        </div>
        <div class="container">
          <el-button type="primary" class="btn-sub" @click="toSub()">提交</el-button>
        </div>
      </el-tab-pane>
      <el-tab-pane label="服务条款" name="third">
        <div style="">
          <tinymce v-model="formData.service_term" :height="300" />
        </div>
        <div class="container">
          <el-button type="primary" class="btn-sub" @click="toSub()">提交</el-button>
        </div>
      </el-tab-pane>
      <!-- <el-tab-pane label="定时任务补偿" name="fourth">定时任务补偿</el-tab-pane> -->
    </el-tabs>
  </div>
</template>

<script>
  import Tinymce from '@/components/Tinymce'
  import { ajaxPost } from '@/api/ajax'
  export default {
    name: 'FuncFormsEdit',
    components: {
      Tinymce
    },
    data() {
      return {
        formData:{
          us_me:null,
          privacy_agreement:null,
          service_term:null,
        },
        editorOption: {},
        system: 'first',
      }
    },
    created() {
      this.getConfig();
    },
    methods: {
      handleClick(tab, event) {
        console.log(tab, event);
      },
      getConfig(){
        ajaxPost("config/get",{type:'home'}).then(res=>{
            this.formData = res.data;
        })
      },
      toSub() {
        let data = this.formData;
        ajaxPost('config/update',{data}).then(res=>{
            if(res.code == 0){
              this.$message({
                message: '编辑成功',
                type: "success",
                duration: 1500,
              })
            }else{
              this.$message.error()({
                message: res.msg
              })
            }
        })
      }
    }
  }
</script>

<style lang="scss">
  .list {
    padding: 20px;
    box-sizing: border-box;

    .container {
      padding: 20px;

      .btn-sub {
        z-index: 9999999;
      }
    }
  }
</style>
